from appium.webdriver.common.mobileby import MobileBy as by

xpath = by.XPATH
css = by.CSS_SELECTOR
link_text = by.LINK_TEXT
partial_link_text = by.PARTIAL_LINK_TEXT
name = by.NAME
tag = by.TAG_NAME
class_name = by.CLASS_NAME
id = by.ID  # 根据resource-id
accessibility_id = by.ACCESSIBILITY_ID  # 根据content-desc
"""
1. 定位单个元素：          xpath, '//*[@...]
2. 定位一组元素：          xpath, s, '//*[@...]
3. 选取一组元素中的一个：  xpath, 0, '//*[@...]
"""
# 设备66b5da5a的屏幕分辨率  1080x1920
size01 = 1080, 1920


# 设备002的分辨率
# size02 = '', ''


class AddContacts:
    add_user_button = id, 'android:id/icon'  # 添加按钮
    local_button = id, 'android:id/button2'  # 本地保存
    user_text = class_name, '//*[contains(@class,\'android.widget.TextView\')]'  # text
    send_name = xpath, '//*[contains(@text,\'姓名\')]'  # 姓名
    send_phone = xpath, '//*[contains(@text,\'电话\')]'  # 手机号
    usr_edit_btn = id, 'com.android.contacts:id/menu_edit'  # 用户详情页编辑按钮
    # 设置
    search_btn = id, 'android:id/input'
    search_text = id, 'android:id/search_src_text'
    search_return = class_name, 'android.widget.ImageButton'
    # 众享亿家
    me = id, 's', 'com.tengchi.zxyjsc:id/tabMeLayout'
    list01 = class_name, 'android.widget.LinearLayout'
    expense = id, 'com.tengchi.zxyjsc:id/tv_consumption_all'  # 累计花费

    # 慕课网
    skip = xpath, '//*[@text="跳过"]'
    # account = accessibility_id, '账号'
    account = xpath, '//*[@content-desc="账号"]'
    a01 = id, 'cn.com.open.mooc:id/tvRightText'
    my_study_xy = [648, 1773], [864, 1920], size01
    # toast_01 = xpath, './/*[contains(@text, "再按一次")]'
    # toast_01 = xpath, '//*[@text="再按一次返回键退出")]'
    my_study = accessibility_id, '我的学习'
    login = id, 'cn.com.open.mooc:id/unLoginContainer'
    login_user = id, 'cn.com.open.mooc:id/accountEdit'
    login_pw = id, 'cn.com.open.mooc:id/passwordEdit'
    submit01 = id, 'cn.com.open.mooc:id/login'
    msg = xpath, '//*[@text="账号未注册"]'
    # 登录后
    my_issue = id, 1, 'cn.com.open.mooc:id/parent'
    issue_01 = class_name, 1, 'android.view.ViewGroup'
    # 开发者头条
    # tt_01 = xpath, '//*[contains(@text, "还在埋头干活")]'
    tt_01 = xpath, '//android.widget.LinearLayout[@resource-id="io.manong.developerdaily:id/btn_item"]'
    tt_02 = xpath, 1, '//android.widget.LinearLayout[@resource-id="io.manong.developerdaily:id/btn_item"]'
    tt_start = [827, 689], [995, 857], size01
